package com.designpattern.adapter;


/**
 * 项目名称: java_algorithm
 * @ClassName AdapterTest
 * @Description
 * @Author huipanxing huipanxing@chinasofti.com   @Date 2021/9/9 15:46
 */
public class AdapterTest {
    public static void main(String[] args) {
        Adaptee adaptee=new Adaptee();
        Target target=new Adapter(adaptee);
        target.outPut5v();
    }
}

class Adaptee {
    public int outPut220v() {
        return 220;
    }
}

interface Target {
    public int outPut5v();
}

class Adapter implements Target {

    private Adaptee adaptee;

    public Adapter(Adaptee adaptee) {
        this.adaptee = adaptee;
    }

    @Override
    public int outPut5v() {
        int i = adaptee.outPut220v();
        System.out.println(String.format("原始电压：%d->输出电压：%d",i,5));
        return 5;
    }
}